package com.jsp.app.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jsp.app.service.AdminOrder;
import com.tamll.bean.ProductOrder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

@Controller
public class AdminOrderController {
    @Autowired
    private AdminOrder adminOrder;

    @GetMapping("OrderPage")
    public String Order1(){
        return adminOrder.Order();
    }

    @GetMapping("OrderMessage")
    public ModelAndView OrderMessage(){
        ModelAndView modelAndView=new ModelAndView();
        Page<ProductOrder> productOrderPage = adminOrder.OrderMessage1();
        List<ProductOrder> records = productOrderPage.getRecords();
        for (ProductOrder productOrder:records) {
            System.out.println(productOrder.toString());
        }
        modelAndView.setViewName("admin/orderManagePage");
        modelAndView.addObject("productOrderList",records);
        return modelAndView;
    }
}
